import { ref, watchEffect } from "vue";
const tabbars = ref(sessionStorage.getItem("tabbars") ? JSON.parse(sessionStorage.getItem("tabbars")) : []);
watchEffect(() => {
  sessionStorage.setItem("tabbars", JSON.stringify(tabbars.value));
});
function getTabPath(tab) {
  return decodeURIComponent(tab.fullPath || tab.path);
}
function useTabbarStore() {
  const addTab = (routeTab) => {
    const tabIndex = tabbars.value.findIndex((tab) => {
      return getTabPath(tab) === getTabPath(routeTab);
    });
    if (tabIndex === -1) {
      tabbars.value.push(routeTab);
    }
  };
  const closeTab = (routeTab) => {
    const tabIndex = tabbars.value.findIndex((tab) => {
      return getTabPath(tab) === getTabPath(routeTab);
    });
    if (tabIndex > -1) {
      tabbars.value.splice(tabIndex, 1);
    }
    return tabIndex;
  };
  return {
    tabbars,
    addTab,
    closeTab
  };
}
export {
  useTabbarStore
};
//# sourceMappingURL=useTabbarStore.mjs.map
